<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<p id="demo">cookie</p>
	<form>
		<p>name:</p>
		<input type="text" name="name" id="name"> 

		<p>psd</p>
		<input type="text" name="psd" id="psd"> <br>

		<button onclick="saveInfoById('name','psd')">saveCookie</button><br>
		<button onclick="readCookie()">readCookie</button>
	</form>

	<script type="text/javascript">
		function saveInfoById(name,psd){
			var names = document.getElementById("name").value;
			var psds  = document.getElementById("psd").value;

			document.cookie =  userName + "=" + names;
			document.write("adsfadsfadsf" + document.cookie);
			alert(document.cookie);
		}

		function readCookie(){
			// var x = document.cookie;
			// alert(x.userName+","+x.password);
			document.getElementById("demo").innerHTML = document.cookie;
			document.write(document.cookie);
		}

	</script>

</body>
</html>


